package com.example.week3.mvp.view;

import android.graphics.Typeface;
import android.os.Bundle;
import android.os.strictmode.CustomViolation;
import android.printservice.CustomPrinterIconCallback;
import android.service.autofill.CustomDescription;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.example.mylibrary.mvp.view.BaseActivity;
import com.example.week3.R;
import com.example.week3.mvp.contract.MainContract;
import com.example.week3.mvp.model.MainModel;
import com.example.week3.mvp.presenter.MainPresenter;
import com.example.week3.mvp.view.fragment.Pig1Fragment;
import com.example.week3.mvp.view.fragment.Pig2Fragment;
import com.example.week3.mvp.view.fragment.Pig3Fragment;
import com.google.android.material.tabs.TabItem;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends BaseActivity<MainPresenter> implements MainContract.View {
    MainPresenter mainPresenter;
    @BindView(R.id.vp)
    ViewPager vp;
    @BindView(R.id.tl)
    TabLayout tl;
    private List<Fragment >list=new ArrayList<>();
    private Pig1Fragment pig1Fragment=new Pig1Fragment();
    private Pig2Fragment pig2Fragment=new Pig2Fragment();
    private Pig3Fragment pig3Fragment=new Pig3Fragment();
    private List<String> title=new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        vp.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
            @NonNull
            @Override
            public Fragment getItem(int position) {
                return list.get(position);
            }

            @Override
            public int getCount() {
                return list.size();
            }

            @Nullable
            @Override
            public CharSequence getPageTitle(int position) {
                return title.get(position);
            }
        });
        tl.setupWithViewPager(vp);
    }

    @Override
    public int bondLayout() {
        return R.layout.activity_main;
    }

    @Override
    public void initView() {
        list.add(pig1Fragment);
        list.add(pig2Fragment);
        list.add(pig3Fragment);
        title.add("首页");
        title.add("订酒店");
        title.add("我的");
    }

    @Override
    public void initData() {
        mainPresenter = new MainPresenter(new MainModel(), this);
    }

    @Override
    public void loadLayout() {

    }

    @Override
    public void hideLayout() {

    }



    @OnClick(R.id.tl)
    public void onViewClicked() {

    }
}
